package springs;

import masses.Mass;


/**
 * @author Jenni Mercado
 * @author Zach Michaelov
 */
public class Muscle extends AbstractSpring {
    /**
     * the rest length of the spring
     */
    private double myRestLength;
    /**
     * the amplitude of the sinusoid
     */
    private double myAmplitude;
    /**
     * period of sine wave
     */
    private final double PERIOD = 2;

    public Muscle (Mass start, Mass end, double length, double kVal,
            double amplitude) {
        super(start, end, length, kVal);

        myAmplitude = amplitude;
        myRestLength = length;
    }

    /**
     * Applies a sinusoidal driving Force to the spring
     * 
     * @param dt change in time used the calculate magnitude of driving Force
     */
    @Override
    public void applyDrivingForce (double dt) {
        double length = myRestLength * myAmplitude
                * Math.sin(Math.toRadians(dt) / PERIOD);
        this.setMyLength(myRestLength + length);
    }
}
